home *** CD-ROM | disk | FTP | other *** search
- /* fdedisp.c file - enhance display_page function */
- #include "stdio.h"
- #include "cminor.h"
- #include "fdparm.h"
- #include "scn.h"
-
- extern char filename[] ;
- extern long filesize ; /* size of file in bytes */
- extern long top_of_page ; /* file position of top of page */
-
- /* special symbols to represent CR, LF, CTL-Z & other ctl chars */
- #define PRT_CR 20
- #define PRT_LF 25
- #define PRT_CTLZ 17
- #define PRT_OTHER 22
- #define ASC_CTLZ 26
-
- int row ; /* current line of page */
- long start ;
- SCN_DATA sc ;
-
- int disp_page()
- {
- char block[ LINE_SIZE ] ;
- int nbytes ;
- int i ; /* index for loops */
- int srow , scol ;
- char s[81] ;
-
- vid_dlr_scn(0,24) ;
- scr_pos(&sc,0,0) ; /* set screen write pos. */
- /* write border line of dashes */
- move_to(top_of_page) ; /* start at top of the page */
- /* write a header line */
- sprintf(s," FILE - %s POSITION - %1d FILE SIZE - %1d ",
- filename, top_of_page, filesize ) ;
- scn_ws(s,&sc) ;
- scn_pos(&sc,1,0) ;
- for( i=1 ; i<=80 ; i=i+1 )
- { scn_ws('-',&sc) ; }
- /* get chars from file until we've written (PAGE_SIZE) lines */
- /* or we've reached the end of the file */
- row = 1 ; /* starting row values */
- start = top_of_page ;
- while( row <= PAGE_SIZE )
- { nbytes = read_line(block,LINE_SIZE) ;
- if( nbytes <= 0 )
- break ;
- scn_pos(&sc,row+1,0) ;
- prtline(block,nbytes) ;
- start = start + nbytes ;
- row = row + 1 ;
- }
- /* write border line of dashes */
- scn_pos(&sc,18,0) ; /* set screen write pos. */
- /* write border line of dashes */
- for( i=1 ; i <=80 ; i=i+1 )
- { scn_wc('-',&sc) ; }
- scn_pos(19,0) ;
- vid_set_cur(19,0) ;
- }
- char hex[] = "0123456789ABCDEF" ;
-
- int prtline(block,nbytes) /* prints one line */
- char block[] ;
- int nbytes ;
- {
- int i ;
- int t ;
- char s[81] ;
-
- sprintf(s,"%81d | ",start) ; /* print file pos. */
- scn_ws(s,sc) ;
-
- for( i=1 ; i< LINE_SIZE ; i=i+1 ) /*print bytes of Hex. */
- { if( i < nbytes )
- { t = (block[i] >> 4 ) & 0xf ;
- scn_wc(hex[t] ,&sc ) ;
- t = block[i] & 0xf ;
- scn_wc( hex[t] , &sc ) ;
- scn_wc( ' ' , &sc ) ;
- }
- else scn_ws(" ",&sc) ; /* out of data - fill in */
- }
-
- scn_ws("| ", &sc) ;
-
- for( i=0 ; i<nbytes ; i=i+1 ) /* display in ASCII form */
- { disp_char( tochar(block[i]) ) ; }
- }
-
- int disp_char(c) /* display one char in ASCII */
- int c ; /* value of char to display */
- {
- /* classify the character and handle accordingly */
-
- if( isgraphic(c))
- ; /* ASCII graphic - just display */
- else if( c == '\n' )
- c = PRT_LF ; /* newline (LF) - display symbol */
- else if( c == '\r' )
- c = PRT_CR ; /* Carr. Return - display symbol */
- else if( c == ASC_CTLZ )
- c = PRT_CTLZ ; /* CTL-Z - display symbol */
- else c = PRT_OTHER ; /* other char - display symbol */
-
- scn_wc(c , &sc) ;
- }
-
-
- int prompt() /* display prompts */
- {
- #define UP_A 24 /* display up arrow */
- #define DN_A 25 /* display down arrow */
- char s[81] ;
-
- scn_pos( &sc , 20 , 0 ) ;
- scn_ws( " Type one of these Input Commands" , & sc ) ;
- scn_pos( &sc , 21 , 0 ) ;
- scn_ws( " HOME = First Page " , & sc) ;
- sprintf(s, " %c = Previous Line " , UP_A) ;
- scn_ws( s , & sc ) ;
- scn_ws( "PG UP = Previous Page " , & sc ) ;
- scn_pos( &sc , 22 , 0 ) ;
- scn_ws( " END = Last Page " , & sc ) ;
- sprintf(s, " %c = Next Line ",DN_A) ;
- scn_ws( s , & sc ) ;
- scn_ws( "PG DN = Next Page " , & sc ) ;
- scn_pos( &sc , 23 , 0 ) ;
- scn_ws( " ESC = Exit Pgm " , & sc ) ;
- scn_ws( "SPACE = Move to position " , &sc ) ;
- scn_pos( &sc , 24 , 0 ) ;
- vid_set_cur( 24 , 0 ) ;
- }
-
-
- int init_disp()
- {
- scn_init(&sc) ;
- }
-
-